package com.zhangxiaofanfan.enums;

import cn.hutool.core.lang.hash.Hash;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * 操作记录
 *
 * @author zhangxiaofanfan
 * @date 2023-10-18 17:18:41
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum OperationEnum {
    CREATE("新增记录"),
    QUERY("查找记录"),
    UPDATE("更新记录"),
    DELETE("删除记录"),
    ;
    private String desc;

    private static final Set<OperationEnum> NEED_SAVE_ORIGIN_RECORD_TYPES = new HashSet<>(List.of(UPDATE, DELETE));

    /**
     * 是否需要对原始数据进行保存
     *
     * @param operationEnum 操作类型
     * @return 是否需要堆原始数据进行保存标志位
     */
    public static boolean needSaveOriginRecord(OperationEnum operationEnum) {
        return NEED_SAVE_ORIGIN_RECORD_TYPES.contains(operationEnum);
    }
}
